// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/accesscontrol/api/OcsPeopleAlarmApi'

import ComClass from '@api/ComQuery'
import ListClass from '@api/accesscontrol/model/OcsPeopleAlarmQueryReq'
import EditClass from '@api/accesscontrol/model/OcsPeopleAlarmHandlerReq'

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询预警列表') {
    const DTO = CORE.grpcDTO(ListClass, param, COM)
    const resp = await CORE.grpc(TIP, CLIENT, 'ocsPeopleAlarmQuery', DTO)
    return [resp.comQuery.totalCount, resp.content || []]
  },

  // —————————————————————————————— 改 —————————————————————————————— //

  transEdit(one) {
    return { ...one, alarmResolveState: one.operate }
  },
  async edit(one, TIP = '修改预警') {
    const DTO = CORE.grpcDTO(EditClass, one)
    await CORE.grpc(TIP, CLIENT, 'ocsPeopleAlarmHandler', DTO)
    return CORE.grpcOK(TIP)
  },
}
